package com.dunshan.prometh.config;

import com.dunshan.prometh.popj.OmsOrder;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.core.instrument.MeterRegistry;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author dunshan
 * @program: dunshan-pef
 * @description: metrics统计
 * @date 2021-09-25 11:17:44
 */
//@Component
//@Aspect
//public class OrderAspect {
//
//    @Pointcut("execution(public * com.dunshan.prometh.controller.*.*(..))")
//    public void pointCut(){}
//
//    private Counter orderCounter;
//
//    private DistributionSummary orderSummary;
//
//    public OrderAspect(MeterRegistry registry) {
//        orderCounter = registry.counter("order_quantity_total", "status", "success");
//        orderSummary = registry.summary("order_amount_total", "status", "success");
//    }
//    @Around("pointCut()")
//    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
//        Object result = pjp.proceed();
//        OmsOrder orderVO = (OmsOrder) result;
//
//        orderCounter.increment();
//        orderSummary.record(orderVO.getTotalAmount().doubleValue());
//
//        return result;
//    }
//}
